<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维修器件金额列表')" />
</head>
<body class="gray-bg">
<div style="background-color: white">
    <a class="btn btn-info btn-outline visible-xs-block" href="#" onclick="$.modal.closeTab()">返&nbsp;回</a>
</div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" th:object="${mPid}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px">维修项目器件名称：</label>
                                <input type="text" name="pName"/>
                            </li>
                            <li>
                                <label style="width: 120px">维修项目器件单价：</label>
                                <input type="text" name="pPrice"/>
                            </li>
                            <li>
                                <label style="width: 100px">维修项目个数：</label>
                                <input type="text" name="pNumber"/>
                            </li>
                            <li>
                                <label style="width: 100px">维修项目总价：</label>
                                <input type="text" name="pSumprice"/>
                            </li>
                            <li class="select-time">
                                <label>日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPNdate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPNdate]"/>
                            </li>
                            <li hidden>
                                <label>外键id：</label>
                                <input type="text" name="mPid"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel(mPid)" shiro:hasPermission="ruoyi:moneys:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:moneys:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:moneys:remove')}]];
        var prefix = ctx + "ruoyi/formoneys";
        var mPid=[[*{mPid}]];
        $(function() {
            var options = {
                url: prefix + "/list/"+mPid,
                showFooter: true,
                createUrl: prefix + "/add/"+mPid,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export/"+mPid,
                showColumns: false,
                striped: true,
                sortName:'pNdate',
                sortOrder:'desc',
                modalName: "维修器件金额",
                columns: [
                    {
                        // title: '序号',
                        formatter(value, row, index){
                            return $.table.serialNumber(index);
                        }
                    },
                {
                    field: 'pId', 
                    title: '维修项目器件id',
                    visible: false
                },
                {
                    field: 'pName', 
                    title: '维修项目器件名称'
                },
                {
                    // field: 'pPrice',
                    title: '维修项目器件单价',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('￥'+row.pPrice);
                        return actions.join('');
                    },
                },
                {
                    field: 'pNumber', 
                    title: '维修项目数量',
                },
                {
                    // field: 'pSumprice',
                    title: '维修项目总价',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('￥'+row.pSumprice);
                        return actions.join('');
                    },
                    footerFormatter: function(value){
                        var sum = 0;
                        for (var i in value) {
                            sum += parseFloat(value[i].pSumprice)
                        }
                        return "维修项目总价: "+sum;
                    }
                },
                {
                    field: 'pNdate', 
                    title: '日期',
                    sortable: true
                },
                {
                    field: 'mPid', 
                    title: '外键id',
                    visible: false
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>